@echo off
chcp 65001 >nul
color 0E

rem 选择设备
set DEVICE=
for /f "skip=1 tokens=1" %%i in ('adb devices 2^>nul ^| find "device"') do (
    if not defined DEVICE set DEVICE=%%i
)

if "%DEVICE%"=="emulator-5554" (
    set DEVICE=-s emulator-5554
    set DEVICENAME=模拟器
) else if "%DEVICE%"=="4f6c2e31" (
    set DEVICE=-s 4f6c2e31
    set DEVICENAME=真机
) else (
    set DEVICE=
    set DEVICENAME=默认设备
)

:loop
cls
echo.
echo ════════════════════════════════════════════════════════════
echo   实时位置监控 - %DEVICENAME%
echo   时间: %date% %time%
echo ════════════════════════════════════════════════════════════
echo.

echo 🌍 GPS Provider 位置:
echo ────────────────────────────────────────────────────────────
adb %DEVICE% shell "dumpsys location 2>/dev/null | grep -A 5 'name=gps' | grep 'latitude\|longitude'" 2>nul
if errorlevel 1 (
    for /f "tokens=*" %%a in ('adb %DEVICE% shell dumpsys location ^| findstr /C:"gps" ^| findstr /C:"latitude"') do echo %%a
    for /f "tokens=*" %%a in ('adb %DEVICE% shell dumpsys location ^| findstr /C:"gps" ^| findstr /C:"longitude"') do echo %%a
)
echo.

echo 📡 Network Provider 位置:
echo ────────────────────────────────────────────────────────────
adb %DEVICE% shell "dumpsys location 2>/dev/null | grep -A 5 'name=network' | grep 'latitude\|longitude'" 2>nul
if errorlevel 1 (
    for /f "tokens=*" %%a in ('adb %DEVICE% shell dumpsys location ^| findstr /C:"network" ^| findstr /C:"latitude"') do echo %%a
    for /f "tokens=*" %%a in ('adb %DEVICE% shell dumpsys location ^| findstr /C:"network" ^| findstr /C:"longitude"') do echo %%a
)
echo.

echo 🔧 Mock Provider 状态:
echo ────────────────────────────────────────────────────────────
adb %DEVICE% shell dumpsys location | findstr /C:"mock" /C:"test" /C:"TestProvider"
echo.

echo ════════════════════════════════════════════════════════════
echo.
echo 💡 这就是第三方APP看到的位置信息
echo.
echo 📱 现在可以：
echo    1. 在你的APP中设置模拟位置
echo    2. 打开其他APP（微信、百度地图等）
echo    3. 观察这里的位置是否变化
echo.
echo 🔄 自动刷新中... (按 Ctrl+C 停止)
echo.

timeout /t 3 >nul
goto loop

